package 面向对象;

import java.util.Scanner;

public class UserLogin {
    public static void main(String[] args) {
        String username = "周星驰";
        String password ="666666";

     for(int i =0 ;i< 3 ;i++) {
         Scanner sc = new Scanner(System.in);
         System.out.println("请输入用户名：");
         String username1 = sc.next();
         System.out.println("请输入密码");
         String password1 = sc.next();

         if (username.equals(username1) && password.equals(password1)) {
             System.out.println("登录成功");
             break;
         } else {
             if(i == 2){
                 System.out.println("您的次数超过三次，"+username+"被锁定，请稍后再试");
             }else{
                 System.out.println("登录失败，用户名或密码错误。你还有"+(2-i)+"次机会");}


         }
     }
    }

}
